<?php

namespace app\wechat\controller;


use think\cache\driver\Redis;

class Openid
{
    public $redis;
    public $handler;

    public function __construct()
    {
        $this->redis = new Redis($options = ['select' => 'cus', 'persistent' => true]);
        $this->handler = $this->redis->handler();
    }

    public function add_openid($appid, $openid)
    {
        $this->handler->sAdd($appid, $openid);
    }

    public function add_set()
    {
        $this->handler->sadd('sets', 'test openid' . '3');
    }

    public function get_set($name)
    {
        $list = $this->handler->smembers($name);
        return $list;
    }

    public function pop_set($name)
    {
        echo $this->handler->spop($name);
    }

    public function del_set($name)
    {
        $this->handler->del($name);
    }
}
